<keira-top-bar [selected]="handlerService.selected" [selectedName]="handlerService.selectedName" [isNew]="handlerService.isNew" />

<div class="container-fluid">
  @if (editorService.loading) {
    <span [translate]="'LOADING'"></span>
  }

  @if (editorService.form && !!editorService.loadedEntityId && !editorService.loading) {
    <div>
      <div class="content-block">
        <keira-query-output [docUrl]="docUrl" [editorService]="editorService" (executeQuery)="save($event)" />
      </div>
      <div class="content-block">
        <form [formGroup]="editorService.form" class="form-group edit-form">
          <div class="row">
            <div class="form-group col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2">
              <label class="control-label" for="School">School</label>
              <keira-generic-option-selector
                [control]="editorService.form.controls.School"
                id="School"
                [optionList]="CREATURE_TEMPLATE_RESISTANCE_SCHOOL"
              ></keira-generic-option-selector>
            </div>
            <div class="form-group col-12 col-sm-6 col-md-4 col-lg-4 col-xl-4">
              <label class="control-label" for="Resistance">Resistance</label>
              <input [formControlName]="'Resistance'" id="Resistance" type="number" class="form-control form-control-sm" />
            </div>
            <div class="col-12 form-error" [hidden]="editorService.isFormIdUnique()">
              <i class="fas fa-exclamation-triangle"></i>
              <span [innerHTML]="'UNIQUE' | translate: { ENTITY_SECOND_ID_FIELD: editorService.entitySecondIdField }"></span>
            </div>
          </div>
        </form>
        <div class="row">
          <div class="col-12">
            <keira-editor-buttons [editorService]="editorService" />
            <ngx-datatable
              id="editor-table"
              class="bootstrap table table-striped text-center datatable-select"
              [rows]="editorService.newRows"
              [headerHeight]="DTCFG.headerHeight"
              [footerHeight]="DTCFG.footerHeight"
              [columnMode]="DTCFG.columnMode"
              [rowHeight]="DTCFG.rowHeight"
              [selectionType]="DTCFG.selectionType"
              (select)="editorService.onRowSelection($event)"
              (keydown.delete)="editorService.deleteSelectedRow()"
            >
              <ngx-datatable-column [minWidth]="30" [maxWidth]="30" [sortable]="false">
                <ng-template let-row="row" ngx-datatable-cell-template>
                  <i [hidden]="!editorService.isRowSelected(row)" class="fas fa-chevron-right"></i>
                </ng-template>
              </ngx-datatable-column>
              <ngx-datatable-column name="School" prop="School" [minWidth]="80" [maxWidth]="150"></ngx-datatable-column>
              <ngx-datatable-column name="Resistance" prop="Resistance" [minWidth]="80" [maxWidth]="150"></ngx-datatable-column>
            </ngx-datatable>
          </div>
        </div>
      </div>
    </div>
  }
</div>
